Libraries
library(survival)
library(FRESA.CAD)
## Loading required package: Rcpp
## Loading required package: stringr
## Loading required package: miscTools
## Loading required package: Hmisc
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
##
## format.pval, units
## Loading required package: pROC
## Type 'citation("pROC")' for a citation.
##
## Attaching package: 'pROC'
## The following objects are masked from 'package:stats':
##
## cov, smooth, var
op <- par(no.readonly = TRUE)
pander::panderOptions('digits', 3)
pander::panderOptions('keep.trailing.zeros',TRUE)
Reporting the Metrics
ROCAUC <- NULL
CstatCI <- NULL
RRatios <- NULL
LogRangp <- NULL
Sensitivity <- NULL
Specificity <- NULL
for (topf in topFive)
{
CstatCI <- rbind(CstatCI,RRanalysis[[topf]]$c.index$cstatCI)
RRatios <- rbind(RRatios,RRanalysis[[topf]]$RR_atP)
LogRangp <- rbind(LogRangp,RRanalysis[[topf]]$surdif$pvalue)
Sensitivity <- rbind(Sensitivity,RRanalysis[[topf]]$ROCAnalysis$sensitivity)
Specificity <- rbind(Specificity,RRanalysis[[topf]]$ROCAnalysis$specificity)
ROCAUC <- rbind(ROCAUC,RRanalysis[[topf]]$ROCAnalysis$aucs)
}
rownames(CstatCI) <- topFive
rownames(RRatios) <- topFive
rownames(LogRangp) <- topFive
rownames(Sensitivity) <- topFive
rownames(Specificity) <- topFive
rownames(ROCAUC) <- topFive
pander::pander(ROCAUC)
| age |
0.588 |
0.490 |
0.685 |
| wt.loss |
0.556 |
0.458 |
0.655 |
pander::pander(CstatCI)
| age |
0.557 |
0.557 |
0.492 |
0.614 |
| wt.loss |
0.513 |
0.513 |
0.455 |
0.571 |
pander::pander(RRatios)
| age |
0.919 |
0.645 |
1.31 |
| wt.loss |
0.785 |
0.462 |
1.33 |
pander::pander(LogRangp)
pander::pander(Sensitivity)
| age |
0.0909 |
0.0463 |
0.157 |
| wt.loss |
0.0496 |
0.0184 |
0.105 |
pander::pander(Specificity)
| age |
0.894 |
0.769 |
0.965 |
| wt.loss |
0.894 |
0.769 |
0.965 |
meanMatrix <- cbind(ROCAUC[,1],CstatCI[,1],Sensitivity[,1],Specificity[,1],RRatios[,1])
colnames(meanMatrix) <- c("ROCAUC","C-Stat","Sen","Spe","RR")
pander::pander(meanMatrix)
| age |
0.588 |
0.557 |
0.0909 |
0.894 |
0.919 |
| wt.loss |
0.556 |
0.513 |
0.0496 |
0.894 |
0.785 |
Cox Model Performance
Here we evaluate the model using the RRPlot() function.
The evaluation of the raw Cox model with RRPlot()
Here we will use the predicted event probability assuming a baseline
hazard for events withing 5 years
timeinterval <- 2*mean(subset(lung,status==1)$time)
h0 <- sum(lung$status & lung$time <= timeinterval)
h0 <- h0/sum((lung$time > timeinterval) | (lung$status==1))
pander::pander(t(c(h0=h0,timeinterval=timeinterval)),caption="Initial Parameters")
Initial Parameters
| 0.85 |
578 |
index <- predict(ml,lung)
rdata <- cbind(lung$status,ppoisGzero(index,h0))
rrAnalysisTrain <- RRPlot(rdata,atProb=c(0.90),
timetoEvent=lung$time,
title="Raw Train: Lung Cancer",
ysurvlim=c(0.00,1.0),
riskTimeInterval=timeinterval)






As we can see the Observed probability as well as the Time vs. Events
are not calibrated.
Cox Calibration
op <- par(no.readonly = TRUE)
calprob <- CoxRiskCalibration(ml,lung,"status","time")
pander::pander(c(h0=calprob$h0,
Gain=calprob$hazardGain,
DeltaTime=calprob$timeInterval),
caption="Cox Calibration Parameters")
Cross-Validation
rcv <- randomCV(theData=lung,
theOutcome = Surv(time,status)~1,
fittingFunction=BSWiMS.model,
trainFraction = 0.95,
repetitions=200,
classSamplingType = "Pro"
)
.[++++].[+-].[+++].[+].[++++].[++].[+++].[+++].[++].[+++]10 Tested:
72 Avg. Selected: 3.6 Min Tests: 1 Max Tests: 5 Mean Tests: 1.388889 .
MAD: 0.4659645
.[++].[+++].[++].[++++].[+++].[+++].[+++].[+++].[+++].[++]20 Tested:
117 Avg. Selected: 3.7 Min Tests: 1 Max Tests: 5 Mean Tests: 1.709402 .
MAD: 0.4716037
.[+++].[+++].[+++].[+++].[++].[+++].[+++].[+++].[+++].[++]30 Tested:
140 Avg. Selected: 3.733333 Min Tests: 1 Max Tests: 6 Mean Tests:
2.142857 . MAD: 0.4723033
.[+].[+++].[++].[+++].[++].[++].[++].[+++].[+++].[+++]40 Tested: 151
Avg. Selected: 3.65 Min Tests: 1 Max Tests: 7 Mean Tests: 2.649007 .
MAD: 0.4734134
.[+++].[++].[+++].[+++].[+++].[+++].[+++].[+++].[+++].[+++]50 Tested:
154 Avg. Selected: 3.7 Min Tests: 1 Max Tests: 9 Mean Tests: 3.246753 .
MAD: 0.4742514
.[+++].[+].[++].[+++].[++].[+++].[+++].[+].[++].[+++]60 Tested: 163
Avg. Selected: 3.633333 Min Tests: 1 Max Tests: 10 Mean Tests: 3.680982
. MAD: 0.4763734
.[++++].[++].[++].[+++].[+++].[++-].[+].[+++].[+++].[+++]70 Tested:
166 Avg. Selected: 3.628571 Min Tests: 1 Max Tests: 10 Mean Tests:
4.216867 . MAD: 0.4769776
.[++].[++++].[+++].[+++].[+++].[+++].[+++].[+++].[+].[+++]80 Tested:
166 Avg. Selected: 3.65 Min Tests: 1 Max Tests: 11 Mean Tests: 4.819277
. MAD: 0.4770715
.[+++].[++].[++].[+++].[+].[++].[+].[+++].[+++].[+++]90 Tested: 168
Avg. Selected: 3.611111 Min Tests: 1 Max Tests: 12 Mean Tests: 5.357143
. MAD: 0.4765639
.[+++].[++++].[++].[++++].[++++].[+++].[+++].[+++].[++].[++]100
Tested: 168 Avg. Selected: 3.65 Min Tests: 1 Max Tests: 13 Mean Tests:
5.952381 . MAD: 0.4765173
.[+++].[++].[+].[+++].[+++].[+++].[+++].[+++].[+++].[+++]110 Tested:
168 Avg. Selected: 3.654545 Min Tests: 1 Max Tests: 13 Mean Tests:
6.547619 . MAD: 0.4763035
.[++].[+++].[+++].[+++].[++-].[+++].[+++].[+++].[++].[+]120 Tested:
168 Avg. Selected: 3.641667 Min Tests: 1 Max Tests: 14 Mean Tests:
7.142857 . MAD: 0.4762139
.[++].[+++].[++].[+++].[+++].[+++].[+++].[+++].[++++].[+++]130
Tested: 168 Avg. Selected: 3.661538 Min Tests: 2 Max Tests: 15 Mean
Tests: 7.738095 . MAD: 0.4762785
.[+++].[+++-].[++].[+++].[++-].[+++].[++++].[+++].[+++].[+-]140
Tested: 168 Avg. Selected: 3.664286 Min Tests: 2 Max Tests: 15 Mean
Tests: 8.333333 . MAD: 0.4762601
.[+++].[+++].[+++].[+++].[+++].[++].[+++].[+++].[+++].[+++]150
Tested: 168 Avg. Selected: 3.68 Min Tests: 2 Max Tests: 17 Mean Tests:
8.928571 . MAD: 0.4761804
.[+++].[+++].[++].[++].[++].[+++].[+++].[+++].[+++].[++]160 Tested:
168 Avg. Selected: 3.675 Min Tests: 2 Max Tests: 18 Mean Tests: 9.52381
. MAD: 0.4756904
.[+++].[+++].[+].[+++].[++].[++++].[++].[+++-].[+++].[++]170 Tested:
168 Avg. Selected: 3.670588 Min Tests: 2 Max Tests: 19 Mean Tests:
10.11905 . MAD: 0.4755905
.[++].[++].[+++].[+++].[++].[+].[++++].[+++-].[+++].[+++]180 Tested:
168 Avg. Selected: 3.666667 Min Tests: 4 Max Tests: 21 Mean Tests:
10.71429 . MAD: 0.4757178
.[+++].[+++].[++].[+++].[++].[+++].[++].[++].[++].[+]190 Tested: 168
Avg. Selected: 3.647368 Min Tests: 4 Max Tests: 23 Mean Tests: 11.30952
. MAD: 0.475742
.[+++].[+++].[++++].[+++].[++].[++].[+++].[+++].[+++].[++]200 Tested:
168 Avg. Selected: 3.655 Min Tests: 4 Max Tests: 23 Mean Tests: 11.90476
. MAD: 0.475456
stp <- rcv$survTestPredictions
stp <- stp[!is.na(stp[,4]),]
bbx <- boxplot(unlist(stp[,1])~rownames(stp),plot=FALSE)
times <- bbx$stats[3,]
status <- boxplot(unlist(stp[,2])~rownames(stp),plot=FALSE)$stats[3,]
prob <- ppoisGzero(boxplot(unlist(stp[,4])~rownames(stp),plot=FALSE)$stats[3,],h0)
rdatacv <- cbind(status,prob)
rownames(rdatacv) <- bbx$names
names(times) <- bbx$names
rrAnalysisTest <- RRPlot(rdatacv,atProb=c(0.90),
timetoEvent=times,
title="Test: Lung Cancer",
ysurvlim=c(0.00,1.0),
riskTimeInterval=timeinterval)






Calibrating the test results
rdatacv <- cbind(status,prob,times)
calprob <- CalibrationProbPoissonRisk(rdatacv)
pander::pander(c(h0=calprob$h0,
Gain=calprob$hazardGain,
DeltaTime=calprob$timeInterval),
caption="Cox Calibration Parameters")
timeinterval <- calprob$timeInterval;
rdata <- cbind(status,calprob$prob)
rrAnalysisTest <- RRPlot(rdata,atProb=c(0.90),
timetoEvent=times,
title="Calibrated Test: Lung",
ysurvlim=c(0.00,1.0),
riskTimeInterval=timeinterval)





